/*
 * @Author: 杨三炮
 * @Date: 2021-11-18 20:05:21
 * @LastEditors: 杨三炮
 * @LastEditTime: 2021-11-19 21:16:14
 * @FilePath: \node\node\routers\test.js
 */
const express = require('express')
const router = express()
const db = require('../model/model')

router.post('/', (req, res) => {
    let sql = `insert into test values(?,?,?)`
    let parmas = [req.body.sno, req.body.name, req.body.phone]
    db.query(sql, parmas).then(result => {
        res.json({
            msg: '插入成功',
            code: 1
        })
    }).catch(err => {
        res.json({
            msg: '插入失败',
            code: 0
        })
    })
})

router.get('/getall', (req, res) => {
    let sql = `select *from test`
    db.query(sql).then(result => {
        res.json(result)
    })
})



module.exports = router